home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / mach / hurd / errnos.awk < prev    next >
Text File  |  1994-05-12  |  4KB  |  155 lines

  1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License
  6. # as published by the Free Software Foundation; either version 2 of
  7. # the License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. # errno.texinfo contains lines like:
  20. # @comment errno.h
  21. # @comment POSIX.1: Function not implemented
  22. # @deftypevr Macro int ENOSYS
  23.  
  24. BEGIN {
  25.     printf "/* This file generated by";
  26.     for (i = 0; i < ARGC; ++i)
  27.       printf " %s", ARGV[i];
  28.     printf ".  */\n";
  29.     print "";
  30.     print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
  31.     print "#ifndef _HURD_ERRNO";
  32.     print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
  33.     print "#endif";
  34.     print "";
  35.     print "#ifdef _ERRNO_H\n";
  36.     print "enum __error_t_codes\n{";
  37.     errno = 0;
  38.     errnoh = 0;
  39.     in_mach_errors = 0;
  40.     in_math = 0;
  41.     edom = erange = "";
  42.     print "#undef EDOM\n#undef ERANGE";
  43.   }
  44.  
  45. $1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
  46. $1 == "@comment" && errnoh == 1 \
  47.   {
  48.     ++errnoh;
  49.     etext = "";
  50.     for (i = 3; i <= NF; ++i)
  51.       etext = etext " " $i;
  52.     next;
  53.   }
  54.  
  55. errnoh == 2 && $1 == "@deftypevr"  && $2 == "Macro" && $3 == "int" \
  56.   {
  57.     e = $4;
  58.     if (e == "EWOULDBLOCK")
  59.       {
  60.     print "#define EWOULDBLOCK EAGAIN /* Operation would block */";
  61.     next;
  62.       }
  63.     x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
  64.                       "_HURD_ERRNO (" errno+1 ")"),
  65.          etext);
  66.     if (e == "EDOM")
  67.       edom = x;
  68.     else if (e == "ERANGE")
  69.       erange = x;
  70.     printf "\t%-16s= _HURD_ERRNO (%d),\n", e, ++errno;
  71.     print x;
  72.     next;
  73.   }
  74. { errnoh=0 }
  75.  
  76. NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
  77.   {
  78.     in_mach_errors = 1;
  79.     print "\n\t/* Errors from <mach/message.h>.  */";
  80.   }
  81. NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
  82.   {
  83.     in_mach_errors = 1;
  84.     print "\n\t/* Errors from <mach/kern_return.h>.  */";
  85.     next;
  86.   }
  87.  
  88. in_mach_errors && $2 == "MACH_IPC_COMPAT" \
  89.   {
  90.     in_mach_errors = 0;
  91.   }
  92.  
  93. in_mach_errors == 1 && NF == 3 && $1 == "#define" \
  94.   {
  95.     printf "\t%-32s= %s,\n", "E" $2, $3;
  96.   }
  97.  
  98. $1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
  99.   {
  100.     in_mig_errors = 1;
  101.     print "\n\t/* Errors from <mach/mig_errors.h>.  */";
  102.     next;
  103.   }
  104. in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
  105.   {
  106.     in_mig_errors = 0;
  107.   }
  108.  
  109. (in_mig_errors && $1 == "#define" && $3 <= -300) || \
  110. (in_device_errors && $1 == "#define") \
  111.   {
  112.     printf "%-32s", sprintf ("\t%-24s= %s,", "E" $2, $3);
  113.     for (i = 4; i <= NF; ++i)
  114.       printf " %s", $i;
  115.     printf "\n";
  116.   }
  117.  
  118. $1 == "#define" && $2 == "D_SUCCESS" \
  119.   {
  120.     in_device_errors = 1;
  121.     print "\n\t/* Errors from <device/device_types.h>.  */";
  122.     next;
  123.   }
  124. in_device_errors && $1 == "#endif" \
  125.   {
  126.     in_device_errors = 0;
  127.   }
  128.  
  129.  
  130. END \
  131.   {
  132.     print "";
  133.     print "};";
  134.     print "";
  135.     printf "#define\t_HURD_ERRNOS\t%d\n", ++errno;
  136.     print "";
  137.     print "\
  138. /* User-visible type of error codes.  It is ok to use `int' or\n\
  139.    `kern_return_t' for these, but with `error_t' the debugger prints\n\
  140.    symbolic values.  */";
  141.     print "#ifdef __USE_GNU";
  142.     print "typedef enum __error_t_codes error_t;"
  143.     print "#endif";
  144.     print "";
  145.     print "/* errno is a per-thread variable.  */";
  146.     print "#include <hurd/threadvar.h>";
  147.     print "#define errno    (*__hurd_errno_location ())";
  148.     print "";
  149.     print "#endif /* <errno.h> included.  */";
  150.     print "";
  151.     print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
  152.     print edom; print erange;
  153.     print "#endif /* <errno.h> not included and need math error codes.  */";
  154.   }
  155.